public class Solution3 {
    public static void main(String[] args) {
        int[] nums = {1,3};
        System.out.println(subsetXORSum(nums));
    }
    public static int sum = 0;
    public static int path = 0;
    public static int subsetXORSum(int[] nums) {
        dfs(nums, 0);
        return sum;
    }

    public static void dfs(int[] nums, int pos) {
        for(int i = pos; i < nums.length; i++) {
            path ^= nums[i];
            sum += path;
            dfs(nums, i + 1);
            path ^= nums[i];//回溯
        }
    }
}
